<template>
  <div class="container">
    <div class="wrapper">
      <div class="icon"><img :src="pageImgArr.iconType" alt=""></div>
      <div class="type01" v-if="audit01"><div class="audit-text" v-html="pageImgArr.descText"></div></div>
      <div class="type02" v-if="audit02">
        <p>店铺资料未通过审核</p>
        <div class="refuse">
          <span class="title">未通过原因：</span>
          <span class="result" v-html="pageImgArr.descText"></span>
        </div>
        <div class="reset"><span @click="reFillUserInfo">重新填写资料</span></div>
      </div>
    </div>
  </div>
</template>

<script>
  import { getAuditStatusApi } from '../../../apis/privateApi.js'
  let loadTimer=null;
  export default {
    data(){
      return{ 
        audit01:true,//1：提交审核中、2：审核未通知、3：审核成功
        audit02:false,//1：提交审核中、2：审核未通知、3：审核成功
        pageImgArr:{ iconType:'', descText:'' }
      }
    },
    created(){
      let _this = this ;
      this.$navtiveUtils.checkLogin();
      window.isLogin = function(u) {
        if (u) {
          let userInfo = { user_id: u };
          window.userInfo = userInfo;
          _this.initPageInfo();
        } else {
          _this.$navtiveUtils.onLogin();
        }
      };
      this.$vux.loading.show({text:'努力加载中'});
    },
    methods:{
      initPageInfo(){
        //审核状态=> 1：提交审核中、2：审核未通知、3：审核成功
        let param= window.userInfo.user_id;
        getAuditStatusApi(param).then(res =>{
          this.$vux.loading.hide();
          window.clearTimeout(window.loadTimer);
          window.loadTimer=null;
          if(res.code==200){
            if(res.data.status==3){
              this.audit01=true;
              this.pageImgArr.iconType=require('../../../assets/img/customer/formAudit2.png');
              this.pageImgArr.descText='您的入驻已通过<br/>工作人员会尽快和您联系';
            }else if(res.data.status==2){
              this.audit01=false;
              this.audit02=true;
              this.pageImgArr.iconType=require('../../../assets/img/customer/formAudit3.png');
              this.pageImgArr.descText=res.data.reason;
            }else{
              this.audit01=true;
              this.pageImgArr.iconType=require('../../../assets/img/customer/formAudit1.png');
              this.pageImgArr.descText='您的资料已经提交<br/>三个工作日内会完成审核';
            }
          }
        }).catch(err =>{
          this.$vux.loading.hide();
          window.clearTimeout(window.loadTimer);
          window.loadTimer=null;
          this.pageImgArr.iconType=require('../../../assets/img/customer/neterror.jpg');
          this.pageImgArr.descText='网络异常，请重试!';
        })
      },
      reFillUserInfo(){
        let url=window.location.origin;
        if(window.location.hostname=='localhost'){
          url= `${url}/views/Customer/manageInfo.html`;
        }else{
          url= `${url}/default/BusinessComeIn/views/Customer/manageInfo.html`;
        };
        window.location.href=url;
      }
    }
  }
</script>
<style lang="less">
html,body{
  font-size: 0.3rem;
  font-family: '微软雅黑';
  background: #ffffff;
}
.vux-popup-dialog.vux-popup-bottom{
  font-size: 0.36rem;
}
.vux-toast,.weui-toast {
  font-size: .32rem;
  line-height: 0.4rem;
}
</style>
<style lang="less" scoped>
.container{
  font-size: 0.36rem;
  font-family: '微软雅黑';
  padding-top: 0.3rem;
  .icon{
    width: 3.22rem;
    height: 3.22rem;
    margin: 0 auto;
  }
  .audit-text{
    padding-top: 0.3rem;
    text-align: center;
    font-size: 0.32rem;
    line-height: 0.5rem;
    color: #999999;
  }
  .type02{
    p{
      line-height: 0.5rem;
      text-align: center;
      font-weight: 600;
      font-size: 0.32rem;
      padding: 0.2rem 0 0.3rem;
    }
    .refuse{
      width: 6rem;
      display: flex;
      color: #999999;
      font-size: 0.28rem;
      margin:  0 auto;
      .title{
        flex: 3;
      }
      .result{
        flex: 7;
        line-height: 0.36rem;
        position: relative;
        top: -0.04rem;
      }
    }
    .reset{
      margin-top: 0.6rem;
      text-align: center;
      color: #09142C;
      span{
        width: 2.8rem;
        font-size: 0.26rem;
        display: inline-block;
        border-radius: 0.1rem;
        padding: 0.2rem 0.4rem;
        background: rgba(255,204,76, 1);
      }
    }
  }
}
</style>